home *** CD-ROM | disk | FTP | other *** search
- Path: engnews1.Eng.Sun.COM!taumet!clamage
- From: nathan@pact.srf.ac.uk (Nathan Sidwell)
- Newsgroups: comp.std.c++
- Subject: Base class access specifiers
- Date: 27 Feb 1996 18:54:36 GMT
- Organization: Inmos
- Sender: usenet@ncs.bris.ac.uk (Usenet news owner)
- Approved: clamage@eng.sun.com (comp.std.c++)
- Message-ID: <DnG4r9.4rr@uns.bris.ac.uk>
- NNTP-Posting-Host: taumet.eng.sun.com
- Content-Type: text
- X-Nntp-Posting-Host: talisker.pact.srf.ac.uk
- X-Newsreader: TIN [version 1.2 PL2]
- Apparently-To: comp-std-c++@britain.eu.net
- Content-Length: 1372
- X-Lines: 50
- Originator: clamage@taumet
-
- I'm having problems determining if the following is legal or not,
- -snip
- class A {
- protected:
- int member;
- void func(A){};
- };
-
- class B : protected A {
- void func(B arg) {
- A::func(A(arg)); // ok
- };
- };
-
- class C : protected B {
- void func(C arg) {
- A::func(A(arg)); // failed
- };
- };
- -snip
-
- I think that the line marked 'failed' is the same as the line marked 'ok'.
-
- However g++ 2.7.2 reports
- foo.cc: In method `void C::func(class C)':
- foo.cc:15: fields of `const A' are inaccessible in `C' due to private
- inheritance
- foo.cc:5: in passing argument 1 of `A::A(const A &)'
- foo.cc:15: in conversion to type `A'
-
- and cfront says,
- "foo.cc", line 15: error: cast: C* -> base A*; protected base class
- "foo.cc", line 15: error: object or pointer missing for A::func() of type
- void A::(A)
-
- SGI CC accepts the code.
-
- As far as I can see section 11.2 of the draft standard can be applied
- recursively to determine the access to A's members in C. This would make
- the two lines have the same meaning.
-
- Where am I going wrong, or are g++ and cfront confused?
-
- nathan
-
- --
- Nathan Sidwell Holder of the Xmris home page
- Chameleon Architecture Group at SGS-Thomson, formerly Inmos
- http://www.pact.srf.ac.uk/~nathan/ Tel 0117 9707182
- nathan@inmos.co.uk or nathan@bristol.st.com or nathan@pact.srf.ac.uk
-
-
- [ comp.std.c++ is moderated. To submit articles: Try just posting with your
- newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
- comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
- Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
- Comments? mailto:std-c++-request@ncar.ucar.edu
- ]
-